package com.hqyj.util;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.stereotype.Component;

@Component
public class MdFiveUtil {
    /*password:要加密的密码
    * salt:盐值后的密码
    * */
    public String changePwd(String password,String salt){
        //创建MD5加密算法对象
        Object obj = new Md5Hash(salt);
        //加密密码
        Object pwd = new SimpleHash("MD5",password,obj,1024);

        return pwd.toString();
    }

    public static void main(String[] args) {
        MdFiveUtil mdFiveUtil = new MdFiveUtil();
        String cat = mdFiveUtil.changePwd("123123", "dog");
        System.out.println(cat);
    }
}
